package com.xiongtian.springframework.beans.factory.support;

import com.xiongtian.springframework.core.io.DefaultResourceLoader;
import com.xiongtian.springframework.core.io.ResourceLoader;

/**
 * @Author: xiongtian
 * @CreateTime: 2025-03-27  10:53
 * @Version: 1.0
 * @Description: 抽象的bean定义读取器
 */

public abstract class AbstractBeanDefinitionReader implements BeanDefinitionReader {

    /**
     * 注册器
     */
    private final BeanDefinitionRegistry registry;

    /**
     * 资源加载器
     */
    private ResourceLoader resourceLoader;

    /**
     * 保证只有子类可以调用
     *
     * @param registry 注册器
     */
    protected AbstractBeanDefinitionReader(BeanDefinitionRegistry registry) {
        this(registry, new DefaultResourceLoader());
    }

    public AbstractBeanDefinitionReader(BeanDefinitionRegistry registry, ResourceLoader resourceLoader) {
        this.registry = registry;
        this.resourceLoader = resourceLoader;
    }

    @Override
    public ResourceLoader getResourceLoader() {
        return resourceLoader;
    }

    @Override
    public BeanDefinitionRegistry getRegistry() {
        return registry;
    }
}
